//  This file is part of Swordbible - http://www.swordwarrior.net
//  Copyright (C) 2003-2008 Manu Mital mital.manu@gmail.com

//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation; either version 2, or (at your option)
//  any later version.

//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.

//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software Foundation,
//  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


#pragma once


#include "AutoRichEditCtrl.h"
#include "VersePicker.h"
#include "SwordBibleDoc.h"
#include "afxwin.h"
#include "afxcmn.h"
#include "CustomRs.h"
#include "MyToolBar.h"


// CVerseLists dialog

class CVerseLists : public CDialog
{
	DECLARE_DYNAMIC(CVerseLists)

public:

	CVerseLists(CWnd* pParent = NULL);   // standard constructor
	virtual ~CVerseLists();
	
	
	inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
	CString list_name;
	CString data;
	void Delete();
	void CreateBlankRecord();
	void AddNew();
	void UpdateBoundData();
	void GenerateError(HRESULT hr, PWSTR pwszDescription);
	BOOL CreateDB(); 
	void CreateDatabaseX();
	
	void DisplayText();
	void LoadToolbar();
	

	CImageList m_image ; // member variable to hold the image list

	sword::ListKey lk; 
	static int active;
	sword::SWModule* pModuleActive;
	
	CMyToolBar m_toolbar;

	
	
	


// Dialog Data
	enum { IDD = IDD_VERSELISTS };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	bool GetAppDirectory( CString& strAppDir );
	CString path;
	

	DECLARE_MESSAGE_MAP()

public:

	void SaveSearchResults();
	void SaveVerseRange(CString vl_data);
	void SaveList(CString listname, CString listdata, BOOL append); 
	void PopulateTree();
	void AppendBibleVersions();
	CString GetListData(CString name);
	virtual BOOL OnInitDialog();
	
	afx_msg void OnAddverse();
	void AppendData(CString& Existing, CString toAppend);
	afx_msg void OnMakeList();
	afx_msg void OnDeleteList();
	afx_msg void OnDeleteVerse();
	afx_msg void OnChangeVersion(UINT nID);
	afx_msg void OnToolbarBibleVersions();
	afx_msg void HideVerseLists();
	afx_msg void OnPrint();
	afx_msg void OnNext();
	afx_msg void OnPrevious();
	afx_msg void OnTreeChangeSel(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnSize(UINT nType, int cx, int cy);

	CAutoRichEditCtrl m_richCtrl;
	CTreeCtrl treeCtrl;

	private:
	void RefreshBoundData();
	CCustomRs m_rsRecSet;
	CString m_strCmdText;
	CString m_strConnection;
	IADORecordBinding* m_piAdoRecordBinding;
	_RecordsetPtr m_pRs;
	BOOL IsAppData;

	
	
	
};
